package com.example.blinkhome.util;

import com.orhanobut.logger.Logger;

import android.content.Context;

public class ndktool {
	
	static{
		System.loadLibrary("ndk");
	}
	
	public static native String sendudpbroadcast(String ip);
	
	public static native String sendudpip(String ip,String mesg);
	
	public static native String getBlinkRouteInfo(String ip);
	
	
	
	
	
	
	public static String scanfBlickRoute(Context context){
		
		String res="";
		try {
			WifiAdmin mWifiAdmin;
			mWifiAdmin = new WifiAdmin(context);
			int ip = mWifiAdmin.getIpAddress();
			String mip=(ip & 0xff) + "." + (ip >> 8 & 0xff) + "."
					+ (ip >> 16 & 0xff) + "." + (ip >>24 &0xff);
			Logger.init();
			Logger.d("mip==="+mip);
			res=sendudpbroadcast(mip);
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}
		return res;
	}

}
